AR Clip SDK
Build AR experiences in Unity that open in AR Clip as an App Clip. Your WebGL content streams in, and ARKit and AR Clip VPS handle localization.
Before you start
- Unity 2020 LTS or newer (tested with 2021+)
- The WebGL build target
- Access to the AR Clip zip uploader
Test on a phone
In the Unity Editor, most AR Clip APIs are wrapped in Application.isEditor. For real tracking,
build for WebGL and test in the AR Clip mobile app.
Install the package
- Open Window → Package Manager.
- Click + → Add package from Git URL….
- Paste
https://github.com/WebAR-Studio/arclip_sdk.gitand confirm.
Before you import, delete any old Assets/ARLib folder. Otherwise you get duplicate symbol
errors like this one:
error CS0433: The type 'ARLibTester' exists in both 'ARLib' and 'Assembly-CSharp'
Import the samples
In Package Manager → AR Clip → Samples:
- Import WebGLTemplates and copy the folder it creates to the root of
Assets/. It then appears under Project Settings → Player → WebGL Template. - Import TransparentBackground and move
TransparentBackground.jslibtoAssets/Plugins. This gives WebGL a transparent background.
Set up the scene
- Add an empty GameObject named
ARClipController. - Add
ARLibControllerto it and assign a camera to therenderCamerafield. - Turn off the Camera component on that GameObject. Set Clear Flags = Solid Color and use RGBA(0,0,0,0) for the background.
- Optional: in the Editor, add
ARLibTester(from Samples) to simulate native callbacks.
Minimal bootstrap script
using UnityEngine;
using ARLib;
public class ARClipBootstrap : MonoBehaviour
{
[SerializeField] private Camera renderCamera;
private void OnEnable()
{
ARLibController.Initialized += HandleInitialized;
ARLibController.VPSPositionUpdated += HandleVpsPose;
}
private void OnDisable()
{
ARLibController.Initialized -= HandleInitialized;
ARLibController.VPSPositionUpdated -= HandleVpsPose;
}
private void Start()
{
ARLibController.SetRenderCamera(renderCamera);
ARLibController.Initialize();
}
private void HandleInitialized()
{
ARLibController.EnableCamera();
ARLibController.EnableAR();
ARLibController.EnableSurfaceTracking("horizontal");
}
private void HandleVpsPose(VPSPoseData pose)
{
Debug.Log($"VPS pose: {pose.Position}");
}
}
Start VPS localization
Set up VPS after initialization and before you start localization:
var settings = new VPSSettings
{
apiKey = "your-api-key",
locationIds = new[] { "your-location-id" }
};
ARLibController.SetupVPS(settings);
ARLibController.StartVPS();
Listen to these events:
ARLibController.VPSInitialized— VPS is ready.ARLibController.VPSPositionUpdated— a new localization pose.ARLibController.OnVPSErrorHappened— an error, as a string.
To tune how often requests are sent at a specific location, use SetSendPhotoDelay,
SetGpsAccuracyBarrier and SetFirstRequestDelay.
Image and surface tracking
- Register images with
AddTrackingImagebefore you turn tracking on. Wait forTrackedImagesArrayUpdateto confirm they loaded. - Call
EnableSurfaceTracking("horizontal" | "vertical" | "both")to find planes. Results come throughSurfaceTrackingUpdated.
Build and upload
- Pick the WebGL template. In Project Settings → Player → WebGL → Resolution and Presentation, choose the template you copied from the package.
- Build. Use File → Build Settings → WebGL → Build.
- Zip. Compress the build so that
index.htmlis at the root of the zip. - Upload. Upload the archive in the zip uploader.
- Test. Scan the QR code you get with the AR Clip iOS app.
Troubleshooting
- No camera feed in WebGL. Make sure
TransparentBackground.jslibis inAssets/Plugins, and the render camera is both assigned and turned off. - No AR events in Editor play mode. This is expected. Use
ARLibTester, or build to WebGL for live data. - Duplicate symbol errors. Make sure you removed the old
ARLibfolder before you imported the package.